package com.dindang.ddm.mvp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.flyco.tablayout.CommonTabLayout;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;

import com.dindang.ddm.di.component.DaggerMainComponent;
import com.dindang.ddm.di.module.MainModule;
import com.dindang.ddm.mvp.contract.MainContract;
import com.dindang.ddm.mvp.presenter.MainPresenter;

import com.dindang.ddm.R;


import butterknife.BindView;

import static com.jess.arms.utils.Preconditions.checkNotNull;

@Route(path = "/activity/MainActivity")
public class MainActivity extends BaseActivity<MainPresenter> implements MainContract.View {
    @BindView(R.id.viewpager)
    ViewPager viewpager;
    @BindView(R.id.commontablayout)
    CommonTabLayout commontablayout;
    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerMainComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .mainModule(new MainModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.activity_main;
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        mPresenter.setNet();
        mPresenter.initView();
        mPresenter.initUser();
        mPresenter.initListener();
    }



    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    public ViewPager getViewpager() {
        return viewpager;
    }

    @Override
    public CommonTabLayout getCommonTabLayout() {
        return commontablayout;
    }

    @Override
    public BaseActivity getActivity() {
        return this;
    }

}
